/**
 * 
 */
package com.jeecms.wicool.entity.shops;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.jeecms.wicool.entity.shops.base.AbstractRedPacket;

/**
 * @author spring
 *
 */
public class RedPacket extends AbstractRedPacket {

	private SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
	
	private String startDate;
	
	private String endDate;
	/**
	 * 
	 */
	private static final long serialVersionUID = -2237131775698242190L;
	
	public void setStartTimeStr(String startTimeStr){
		try {
			Date date = format1.parse(startTimeStr);
			setStartTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public String getStartTimeStr(){
		if(this.getStartTime() == null){
			setStartTime(new Timestamp(new Date().getTime()));
		}
		Date date = new Date(this.getStartTime().getTime());
		return format1.format(date);
	}
	
	public void setEndTimeStr(String endTimeStr){
		try {
			Date date = format1.parse(endTimeStr);
			setEndTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	
	public String getEndTimeStr(){
		if(this.getEndTime() == null){
			setEndTime(new Timestamp(new Date().getTime()));
		}
		Date date = new Date(this.getEndTime().getTime());
		return format1.format(date);
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
		try {
			Date date = format1.parse(startDate);
			setStartTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
		try {
			Date date = format1.parse(endDate);
			setEndTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	
	
}
